<?php

class StaticPagesController extends Controller {

	public $layout='//layouts/main';
	
	public function init(){
		Yii::app()->theme = 'orange';
		parent::init();
	}
	/*
	public function actionView($id) {
		$this->render('view', array(
			'model' => $this->loadModel($id, 'StaticPage'),
		));
	}
	*/
	public function actionView($alias) {
		$this->render('view', array(
			'model' => StaticPage::model()->findByAttributes(array('alias'=>$alias)),
		));
	}
/*
	public function actionCreate() {
		$model = new StaticPage;

		$this->performAjaxValidation($model, 'static-page-form');

		if (isset($_POST['StaticPage'])) {
			$model->setAttributes($_POST['StaticPage']);

			if ($model->save()) {
				if (Yii::app()->getRequest()->getIsAjaxRequest())
					Yii::app()->end();
				else
					$this->redirect(array('view', 'id' => $model->id));
			}
		}

		$this->render('create', array( 'model' => $model));
	}

	public function actionUpdate($id) {
		$model = $this->loadModel($id, 'StaticPage');

		$this->performAjaxValidation($model, 'static-page-form');

		if (isset($_POST['StaticPage'])) {
			$model->setAttributes($_POST['StaticPage']);

			if ($model->save()) {
				$this->redirect(array('view', 'id' => $model->id));
			}
		}

		$this->render('update', array(
				'model' => $model,
				));
	}

	public function actionDelete($id) {
		if (Yii::app()->getRequest()->getIsPostRequest()) {
			$this->loadModel($id, 'StaticPage')->delete();

			if (!Yii::app()->getRequest()->getIsAjaxRequest())
				$this->redirect(array('admin'));
		} else
			throw new CHttpException(400, Yii::t('app', 'Your request is invalid.'));
	}

	public function actionIndex() {
		$dataProvider = new CActiveDataProvider('StaticPage');
		$this->render('index', array(
			'dataProvider' => $dataProvider,
		));
	}

	public function actionAdmin() {
		$model = new StaticPage('search');
		$model->unsetAttributes();

		if (isset($_GET['StaticPage']))
			$model->setAttributes($_GET['StaticPage']);

		$this->render('admin', array(
			'model' => $model,
		));
	}
*/
}